type IStatus = {
  CANCELED: string;
  DELETED: string;
  DELETE_FAILED: string;
  DELETING: string;
  PAUSED: string;
  QUEUED: string;
  REJECTED: string;
  SUBMITTED: string;
  SUBMITTING: string;
  UPLOADING: string;
  UPLOAD_EXISNAME: string;
  UPLOAD_FAILED: string;
  UPLOAD_FINALIZING: string;
  UPLOAD_RETRYING: string;
  UPLOAD_SUCCESSFUL: string;
};

interface IChildFolderConfig {
  level1FolderPath: string;
  level2FolderPath: string;
  data: { [key: string]: any }[]
}

interface IUploaderProps {
  // 自定义样式
  uploadListClassName?: string;
  // 是否显示重名策略弹框
  showStrategyModal?: boolean;
  // 文件类型
  accept?: { type: string }[];
  // 文件上传模式
  fileMode?: string;
  // 文件大小
  fileSize?: string;
  // 是否固定高度
  fixedHeight?: boolean;
  // 是否以缩略图展示
  thumbnail?: boolean;
  // 上传类型
  uploadType?: string;
  // 是否只读
  readOnly?: boolean;
  //文件夹id
  folderId?: string | number;
  //文件操作类型，UPLOAD|UPDATE  上传|更新
  fileModel?: string;
  //文件id，更新文件的时候需要传递
  fileId?: string | number;
  //文件名，更新文件的时候需要传递
  fileName?: string;
  // 是否支持文件夹上传
  uploadfolder?: boolean;
  // 是否多选
  showAllRemoveBtn?: boolean;
  // 是否以浮层的形式展示列表
  showListFloatLayer?: boolean;
  //最多上传多少文件个数
  itemLimit?: number;
  //最小文件大小（以字节为单位）。
  minSizeLimit?: number;
  // 是否多选
  multiple?: boolean;
  // 最大上传数量
  maxNumber?: string;
  collapsible?: boolean;
  //最大文件大小（以字节为单位）。
  sizeLimit?: number;
  //上传块大小,默认5242880
  chunkSize?: number;
  //更新时候需要|更新策略
  strategy?: string;
  //禁止拖拽多文件上传
  dropMultiple?: boolean;
  //允许上传的文件类型 ["png","jpg"]
  allowedExtensions?: Array<string>;
  // 是否显示上传按钮
  showUploadBtn?: boolean;
  // 上传的文件列表
  fileList?: Array<any>;
  // 重名策略
  repeatStrategy?: string;
  // 子文件夹创建策略
  createChildrenFolder?: string | IChildFolderConfig;
  // 已上传文件列表
  defaultFileList?: Array<any>;
  // 查看模式
  viewMode?:string;
  // 上传限速
  uploadSpeed?: number;
  // 是否开启秒传
  secondPass?: boolean;
  // 事件集合
  events?: any;
  // 列表单击事件
  onItemClick?: (file?: any) => void;
  // 列表删除事件
  onItemRemove?: (file?: any) => void;
  // 列表退出事件
  onItemCancel?: (file?: any) => void;
  // 列表全部删除事件
  onAllRemove?: (fileList?: any) => void;
  //上传状态变更事件
  onStatusChange?: (data: { id: string | number; oldStatus: string; status: string }) => void;
  // 上传完成后的回调
  onUploadComplete?: (params: {
    successList: File[];
    failedList: File[];
    fileList: File[];
  }) => void;
  // 浮层列表点击后的回调
  onFloatLayerClick?: (type: string) => void;
  onProgress?: (fileId: number,name: string,bytesUploaded: number,totalSize: number) => void
  onTotalProgress?: (bytesUploaded: number, totalSize: number) => void
  onStrategyList?: <T extends {label:string, value:string}[]>(folderId:string, options: T) => T  // 自定义文件名策略
  onStrategyFileNameFormat?: (name: string, file: object) =>  string // 策略文件名格式化
  onFileNameFormat?: (name: string, fileid?: string) =>  string //文件名格式化
}

interface BlobWrapper {
  blob?: Blob;
  name?: string;
}

interface IUploadListProps extends IUploaderProps {
  uploader: {
    on: (type: string, callback: Function) => void;
    off: (type: string, callback: Function) => void;
    options: {
      chunking: {
        enabled: boolean;
      };
      deleteFile: {
        enabled: boolean;
      };
    };
    qq: {
      status: IStatus;
    };
    methods: {
      addFiles: (fileList: { [key: string]: any }[], params: { [key: string]: any }) => void;
      addInitialFiles: (fileList: { [key: string]: any }[]) => void;
      getUploads: (params: { [key: string]: any }) => { [key: string]: any }[];
      getFile: (id: string | number) => { [key: string]: any };
      retry: (id: string | number) => void;
      pauseUpload: (id: string | number, bool?: boolean) => void;
      continueUpload: (id: string | number, params: { isClearFile?: boolean; isContinueUpload?: boolean; isAllContinueUpload?: boolean; }) => void;
      getSize: (id: string | number) => number;
      getName: (id: string | number) => string;
      cancel: (id: string | number) => void;
      deleteFile: (id: string | number) => void;
      setName: (fileId: string | number, newName: string) => void;
      getInProgress: () => any;
      _handler: {
        reset: () => void;
      };
      _uploadData: {
        reset: () => void;
      };
    };
  };
  statusEnum: IStatus;
}

interface IUploadListState {
  visibleFiles: any[];
  renameFiles: {
    id: string | number;
    status: string;
    filename: string;
    size: string | number;
    type: string;
    result?: object; // 如果已经处理了重名就存在值
  }[];
  reNameStrategy: {
    folderId?: string | number;
    strategy: string;
  };
  isPackUp: boolean;
  uploadStatus: string;
  pausable: boolean;
  resumable: boolean;
  itemRename?: {
    id: string | number;
    file: any;
  };
  surplusNum: number;
  isAllPause: boolean;
}

interface IUploadListCtx {
  visibleFiles: any[];
  isPackUp: boolean;
  uploadStatus: string;
  pausable: boolean;
  surplusNum: number;
  animationsDisabled?: boolean;
  onDelectAll: () => void;
  onUnwindPackUp: () => void;
  onResumPausedFiles: (type: string) => void;
  onClickFileItem: (fileId: string | number, status: string) => void;
  showRenameModal: (id?: string | number, callback?: Function) => void;
}

export { IStatus, IUploaderProps, BlobWrapper, IUploadListProps, IUploadListState, IUploadListCtx, IChildFolderConfig };
